package com.hhit.bigscreenbackmanage.controller.jsgl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.common.Response;
import com.hhit.bigscreenbackmanage.entity.jsgl.TJsglGljh;
import com.hhit.bigscreenbackmanage.entity.jsgl.TJsglSjzlwt;
import com.hhit.bigscreenbackmanage.service.jsgl.TJsglSjzlwtService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/jsgl/sjzlwt")
public class SjzlwtController {

    private Logger log = LoggerFactory.getLogger(SjzlwtController.class);

    @Autowired
    TJsglSjzlwtService tJsglSjzlwtService;

    /**
     * 查询 技术设计质量问题情况
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSjzlwtList")
    public Response getSjzlwtList(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglSjzlwtService.querySjzlwtList(jsonObject);
            return Response.createResponseBySuccess("查询技术设计质量问题情况成功",result);
        }catch (Exception e){
            log.error("查询技术设计质量问题情况失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询技术设计质量问题情况失败");
        }
    }

    /**
     *设计质量-初步设计-初设评审完成
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getCbsjCspswcList")
    public Response getCbsjCspswcList(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglSjzlwtService.queryCbsjCspswcList(jsonObject);
            return Response.createResponseBySuccess("查询设计质量-初步设计-初设评审完成情况成功",result);
        }catch (Exception e){
            log.error("查询技术设计质量问题情况失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询设计质量-初步设计-初设评审完成情况失败");
        }
    }

    /**
     * 查询 设计变更情况
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSjzlwtSjbgList")
    public Response getSjzlwtSjbgList(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglSjzlwtService.querySjzlwtSjbgList(jsonObject);
            return Response.createResponseBySuccess("查询设计变更情况成功",result);
        }catch (Exception e){
            log.error("查询设计变更情况失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询设计变更情况失败");
        }
    }

    /**
     * 查询 约谈通报情况
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSjzlwtYttbList")
    public Response getSjzlwtYttbList(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglSjzlwtService.querySjzlwtYttbList(jsonObject);
            return Response.createResponseBySuccess("查询约谈通报情况成功",result);
        }catch (Exception e){
            log.error("查询约谈通报情况失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询约谈通报情况失败");
        }
    }

    /**
     * 查询 质量事件情况
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSjzlwtZlsjList")
    public Response getSjzlwtZlsjList(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglSjzlwtService.querySjzlwtZlsjList(jsonObject);
            return Response.createResponseBySuccess("查询质量事件情况成功",result);
        }catch (Exception e){
            log.error("查询质量事件情况失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询质量事件情况失败");
        }
    }

    /**
     * 查询 设计质量问题统计详情
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSjzlwtTjList")
    public Response getSjzlwtTjList(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglSjzlwtService.querySjzlwtTjList(jsonObject);
            return Response.createResponseBySuccess("查询设计质量问题统计详情成功",result);
        }catch (Exception e){
            log.error("查询设计质量问题统计详情失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询设计质量问题统计详情失败");
        }
    }

    /**
     * 查询 设计质量统计
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSjzlTjCount")
    public Response getSjzlTjCount(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Integer> result = tJsglSjzlwtService.querySjzlTjCount(jsonObject);
            return Response.createResponseBySuccess("查询设计质量统计成功",result);
        }catch (Exception e){
            log.error("查询设计质量统计失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询设计质量统计失败");
        }
    }

    /**
     * 查询 设计质量分类统计
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSjzlByParam")
    public Response getSjzlByParam(@RequestBody JSONObject jsonObject){
        try{
            List<Map<String, Object>> result = tJsglSjzlwtService.querySjzlByParam(jsonObject);
            return Response.createResponseBySuccess("查询设计质量分类统计成功",result);
        }catch (Exception e){
            log.error("查询设计质量分类统计失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询设计质量分类统计失败");
        }
    }

    /**
     * 查询设计专业分类统计（重写）
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSjzlByParam_sjzy")
    public Response getSjzlByParam_sjzy(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglSjzlwtService.getSjzlByParam_sjzy(jsonObject);
            return Response.createResponseBySuccess("查询设计质量分类统计成功",result);
        }catch (Exception e){
            log.error("查询设计质量分类统计失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询设计质量分类统计失败");
        }
    }

    /**
     * 查询 设计变更统计
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSjbgCount")
    public Response getSjbgCount(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Integer> result = tJsglSjzlwtService.querySjbgCount(jsonObject);
            return Response.createResponseBySuccess("查询设计变更统计成功",result);
        }catch (Exception e){
            log.error("查询设计变更统计失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询设变更统计失败");
        }
    }

    /**
     * 删除 技术设计质量问题情况记录
     * @param jsonObject
     * @return
     */
    @RequestMapping("/deleteSjzlwtRecord")
    public Response deleteSjzlwtRecord(@RequestBody JSONObject jsonObject){
        try{
            tJsglSjzlwtService.deleteSjzlwtRecord(jsonObject);
            return Response.createResponseBySuccess("删除技术设计质量问题情况记录成功");
        }catch (Exception e){
            e.printStackTrace();
            return Response.createResponseByError("删除技术设计质量问题情况记录失败: "+e.getMessage());
        }
    }

    /**
     * 删除 设计变更情况记录
     * @param jsonObject
     * @return
     */
    @RequestMapping("/deleteSjzlwtSjbgRecord")
    public Response deleteSjzlwtSjbgRecord(@RequestBody JSONObject jsonObject){
        try{
            tJsglSjzlwtService.deleteSjzlwtSjbgRecord(jsonObject);
            return Response.createResponseBySuccess("删除设计变更情况记录成功");
        }catch (Exception e){
            e.printStackTrace();
            return Response.createResponseByError("删除设计变更情况记录失败: "+e.getMessage());
        }
    }


    /**
     * 删除 约谈通报情况记录
     * @param jsonObject
     * @return
     */
    @RequestMapping("/deleteSjzlwtYttbRecord")
    public Response deleteSjzlwtYttbRecord(@RequestBody JSONObject jsonObject){
        try{
            tJsglSjzlwtService.deleteSjzlwtYttbRecord(jsonObject);
            return Response.createResponseBySuccess("删除约谈通报情况记录成功");
        }catch (Exception e){
            e.printStackTrace();
            return Response.createResponseByError("删除约谈通报情况记录失败: "+e.getMessage());
        }
    }

    /**
     * 删除 质量事件情况记录
     * @param jsonObject
     * @return
     */
    @RequestMapping("/deleteSjzlwtZlsjRecord")
    public Response deleteSjzlwtZlsjRecord(@RequestBody JSONObject jsonObject){
        try{
            tJsglSjzlwtService.deleteSjzlwtZlsjRecord(jsonObject);
            return Response.createResponseBySuccess("删除质量事件情况记录成功");
        }catch (Exception e){
            e.printStackTrace();
            return Response.createResponseByError("删除质量事件情况记录失败: "+e.getMessage());
        }
    }
}
